Skip to content

Statics #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 26, 2017
Merged

Statics #146

merged 7 commits into from
Oct 26, 2017

Conversation

eddow
Copy link
Contributor

@eddow eddow commented Sep 14, 2017

#135 (comment)

Class' static member are browsed and added to the generated class.

Copy link
Member

@HerringtonDarkholme HerringtonDarkholme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than potential edge cases, code style needs updating as well.

test/test.ts Outdated
@@ -256,4 +256,14 @@ describe('vue-class-component', () => {
expect(parent.value).to.equal('parent')
expect(child.value).to.equal('child')
})

it('forwardStatics', function () {
debugger;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

src/component.ts Outdated
const rv = Super.extend(options);

for(let sttc in Component)
if(!(sttc in function() {}) && Component.hasOwnProperty(sttc))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if hasOwnProperty will impact component inheritance. A test case should be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written like that, a child class doesn't forward the statics of its parent. hasOwnProperty means the the property is in the object, not its prototype.

I am not sure of the question, therefore I don't know if it answers - what do you mean by "impact component inheritance" ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider

@Compoent class Parent extends Vue { static config = {} }
@Compoent class Child extends Parent {}

Child.config // expect an object {}

Written like that, a child class doesn't forward the statics of its parent.

I think you already understand me. And I even suspect whether we should support inheritance any way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, Child.config would, in this implementation, retrieve undefined
Beside beeing the easiest to implement, I just checked on how typescript managed static' legacy, and it seems coherent with the usual behaviour.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it simple. vue-class-component is for both Babel and TS users. Rolling out a babel compatible version might be challenging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, is it still a "change requested" or an acceptation?

src/component.ts Outdated
const rv = Super.extend(options);

for(let sttc in Component)
if(!(sttc in function() {}) && Component.hasOwnProperty(sttc))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!(sttc in function() {})

Is this necessary? Looks like only using hasOwnProperty is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will for instance avoid statics to override name or apply

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why shouldn't they be overridden? Is that stated in the spec?
I think we should follow the es spec as possible since the user would expect it.

src/component.ts Outdated

for(let sttc in Component)
if(!(sttc in function() {}) && Component.hasOwnProperty(sttc))
rv[sttc] = Component[sttc];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename rv to Extended and also sttc to key? I cannot see what the current name means...

src/component.ts Outdated
return Super.extend(options)
const rv = Super.extend(options);

for(let sttc in Component)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add curly braces for for and if expressions?

@HerringtonDarkholme
Copy link
Member

@ktsn this implementation is not compatible with Babel, is this fine to you?

@ktsn
Copy link
Member

ktsn commented Sep 15, 2017

@HerringtonDarkholme I think it's ok that it does not have partial feature of class like inheritance since we can incrementally add them when we need. But at least it should be consistent with es spec that we include into vue-class-component.

@eddow
Copy link
Contributor Author

eddow commented Sep 16, 2017

Sorry for latency.
So, I also checked and there is no "parasite" property that I was afraid of finding, it indeeds works like expected

@ktsn
Copy link
Member

ktsn commented Oct 26, 2017

@HerringtonDarkholme This looks good to me. Would you have any concern for this feature/implementation still?

@ktsn ktsn merged commit 9d64be7 into vuejs:master Oct 26, 2017
@ktsn ktsn mentioned this pull request Oct 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants